<template>
    <div>
        <div class="mui-numbox" data-numbox-min='1' >
					<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
					<input id="test" class="mui-input-numbox" type="number" value="1" ref="numbers" @change="countChange"/>
					<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		</div>
    </div>
</template>
<script>
import mui from '../../lib/mui/dist/js/mui.js'
    export default {
       
        mounted() {
            mui('.mui-numbox').numbox()
        },
         methods:{
            countChange(){
                // 每当文本框数据修改的时候，立即把最新的数据通过事件调用，传递给父组件
                this.$emit('goodnums',parseInt(this.$refs.numbers.value))
            }
        },
        props:['max'],
        watch:{
            // 使用js API设置number的最大值
            'max':function(a,b){mui('.mui-numbox').numbox().setOption('max',a)}
        }
    }
</script>
<style lang="scss" scoped>

</style>
